<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
     public function _initialize () {
		 //保证页面编码为UTF-8
		header("Content-type: text/html; charset=utf-8");
	 }

	public function loginHandle(){
			sleep(2);
			$str=file_get_contents('php://input');
			$arr=json_decode($str);
			$con['cs_email']=$arr->login_email;
			$con['cs_pwd']=md5($arr->login_pwd);
			$list=M("client")->where($con)->find();
			$data['status']=0;
			if(!$list){
				$data['info']="用户名或密码错误";
				$this->ajaxReturn($data);
			}
			if(!$list['cs_status']){
				$data['info']="未激活的账户";
				$this->ajaxReturn($data);
			}
			session("cs_id",$list['cs_id']);
			$data['status']=1;
			$data['info']="登录成功！";
			$data['url']=U("Account/index");
			$this->ajaxReturn($data);
	}
	

	//地址信息
			public function area_json($current=1,$page_size=10){
				 $oop=M("areas");
				 $data['count']      = (int)$oop->count();// 查询满足要求的总记录数
				 //每次查询N条记录
				 $data['page_size']=$page_size<=0  || $page_size>$data['count'] ? 10 : (int)$page_size;
				  //分页数
				 $data['page_num']=ceil($data['count']/$data['page_size']);
				  
				 //当前页
				 $data['current']=$current<=0 || $current >$data['page_num'] ? 1 : (int)$current;
				 		 
				  //每次查询显示10条记录
				$data['list']=$oop->limit(($data['current']-1)*$data['page_size'],$data['page_size'])->order("area_id desc")->select();
				$this->ajaxReturn($data);
			}

	
	public function testform(){
		$this->display();
	}

	
}